#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	map<char, char> mp;
	mp['a'] = mp['b'] = mp['c'] = '0';
	char var, c, val;
	while ((var = getchar()) && (var != '\n') && (var != EOF))
	{
		getchar();
		getchar();
		val = getchar();
		getchar();
		if ('0' <= val && val <= '9')
		{
			mp[var] = val;
		}
		else
		{
			mp[var] = mp[val];
		}
	}
	cout << mp['a'] << ' ' << mp['b'] << ' ' << mp['c'];
}
